package com.bdqn.config;

import com.bdqn.interceptor.LoginInterceptor;
import com.bdqn.interceptor.MyInterceptor1;
import com.bdqn.interceptor.MyInterceptor2;
import com.bdqn.interceptor.MyInterceptor3;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Author 27435
 * @Date 2025/1/217:37
 * @Version 1.0
 */

@Configuration
public class SpringMvcConfig extends WebMvcConfigurationSupport {
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/css/**")
                .addResourceLocations("/css/");
        registry.addResourceHandler("/js/**")
                .addResourceLocations("/js/");
        registry.addResourceHandler("/images/**")
                .addResourceLocations("/images/");
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login");

        MyInterceptor1 myInterceptor1 = new MyInterceptor1();
        registry.addInterceptor(myInterceptor1)
                .addPathPatterns("/my");

        MyInterceptor2 myInterceptor2 = new MyInterceptor2();
        registry.addInterceptor(myInterceptor2)
                .addPathPatterns("/my");

        MyInterceptor3 myInterceptor3 = new MyInterceptor3();
        registry.addInterceptor(myInterceptor3)
                .addPathPatterns("/my");
    }
}
